#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e5 + 5;

int n, m;
int head[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
int st[N][20], dep[N];
void dfs(int u, int fu) {
  st[u][0] = fu;
  dep[u] = dep[fu] + 1;
  rep(i, 1, 18) st[u][i] = st[st[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  per(i, 18, 0) if (d & (1 << i)) u = st[u][i];
  if (u == v) return u;
  per(i, 18, 0) if (st[u][i] != st[v][i]) u = st[u][i], v = st[v][i];
  return st[u][0];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 2, n) {
    int u, v;
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    int xy = lca(x, y), yz = lca(y, z), xz = lca(x, z);
    int mn = max({dep[xy], dep[yz], dep[xz]});
    int mx = min({dep[xy], dep[yz], dep[xz]});
    if (mn == dep[xy])
      cout << xy;
    else if (mn == dep[yz])
      cout << yz;
    else
      cout << xz;
    cout << ' ' << dep[x] + dep[y] + dep[z] - mn - mx * 2 << endl;
  }
  return 0;
}